class Solution {
public:
    int jump(vector<int>& nums) {
        int maxP =0;
        int n=nums.size();
        int end =0;
        int step=0;
        for (int i=0 ;i<n-1;i++)
        {
            if (maxP>=i)
            {
                maxP = max(maxP,i+nums[i]);
                if (i == end)
                {
                    end =maxP;
                    step++;
                }
            }
        }

        return step;
    }
};